/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package vista;

import com.alee.laf.panel.WebPanel;
import com.alee.laf.rootpane.WebFrame;
import com.alee.laf.tabbedpane.WebTabbedPane;
import java.awt.Color;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.BoxLayout;
import javax.swing.ImageIcon;

/**
 *
 * @author Edder
 */
public class FrmPrincipal extends WebFrame{
    private ItemPrincipal movimientos,
            gestionCategorias,
            gestionAlmacenes, 
            gestionArticulos;
    
    public static boolean bolFrmAlmacenes;
    public static boolean bolFrmCategorias;
    public static boolean bolFrmArticulos;
    public static boolean bolFrmMovimiento;
    
    FrmPrincipal(){
        setTitle("Bodega");
        setDefaultCloseOperation(WebFrame.EXIT_ON_CLOSE);
        setSize(400, 500);
        setShowResizeCorner(false);
        setShowMaximizeButton(false);
        setLocationRelativeTo(null);        
        initComponents();
        FrmPrincipal.bolFrmAlmacenes = false;
    }

    private void initComponents() {
        this.add(new WebPanel(){
            {
                this.setBackground(Color.white);
                add(new WebTabbedPane(){
                    {
                        this.setBackground(Color.white);
                        addAlmacenModule(this);
                        addComprasModule(this);
                        addVentasModule(this);
                        addCajaModule(this);
                        addSeguridadModule(this);
                    }            
                });
            }
        });
    }
    
    private void addAlmacenModule(WebTabbedPane owner){
        owner.addTab("Almacén", new WebPanel(){
            {
                this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
                movimientos = new ItemPrincipal(
                        new ImageIcon(getClass().getResource("/resources/img/in_out.png")),
                        "Movimientos");
                gestionCategorias = new ItemPrincipal(
                        new ImageIcon(getClass().getResource("/resources/img/in_out.png")),
                        "Categorías");
                gestionAlmacenes = new ItemPrincipal(
                        new ImageIcon(getClass().getResource("/resources/img/in_out.png")),
                        "Almacenes");
                gestionArticulos = new ItemPrincipal(
                        new ImageIcon(getClass().getResource("/resources/img/in_out.png")),
                        "Artículos");
                
                this.add(movimientos,
                        gestionCategorias,
                        gestionAlmacenes,
                        gestionArticulos);                
            }
        });
        
        this.movimientos.addMouseListener(new MouseAdapter(){
            @Override
            public void mouseClicked(MouseEvent me){
                if (!FrmPrincipal.bolFrmMovimiento) {
                    FrmPrincipal.bolFrmMovimiento = true;
                    new FrmMovimiento().setVisible(true);
                }
            }
        });
        this.gestionCategorias.addMouseListener(new MouseAdapter(){
            @Override
            public void mouseClicked(MouseEvent me){
                if(!FrmPrincipal.bolFrmCategorias){
                    FrmPrincipal.bolFrmCategorias = true;
                    new FrmCategorias().setVisible(true);
                }
            }
        });
        this.gestionAlmacenes.addMouseListener(new MouseAdapter(){
            @Override
            public void mouseClicked(MouseEvent me){
                if(!FrmPrincipal.bolFrmAlmacenes){
                    FrmPrincipal.bolFrmAlmacenes = true;
                    new FrmAlmacenes().setVisible(true);
                }
            }
        });
        this.gestionArticulos.addMouseListener(new MouseAdapter(){
            @Override
            public void mouseClicked(MouseEvent me){
                if(!FrmPrincipal.bolFrmArticulos){
                    FrmPrincipal.bolFrmArticulos = true;
                    new FrmArticulos().setVisible(true);
                }
            }
        });
    }
    
    private void addComprasModule(WebTabbedPane owner){
        owner.addTab("Compras", new WebPanel(){
            {
                
            }
        });
    }
    
    private void addVentasModule(WebTabbedPane owner){
        owner.addTab("Ventas", new WebPanel(){
            {
                
            }
        });
    }
    
    private void addCajaModule(WebTabbedPane owner){
        owner.addTab("Caja", new WebPanel(){
            {
                
            }
        });
    }
    
    private void addSeguridadModule(WebTabbedPane owner){
        owner.addTab("Seguridad", new WebPanel(){
            {
                
            }
        });
    }
}
